package com.nlscan.qdkit.ui.publico.util;

import com.quvii.qvlib.util.LogUtil;
import com.quvii.qvlib.util.QvSpUtil;

/**
 * 设备信息缓存, 当前只保存服务器上的设备UID列表
 */
public class SpDeviceUtil extends QvSpUtil {
    private static final String KEY_DEVICE_LIST = "dev_list";

    @Override
    protected String getSharePreferencesName() {
        return "device_cache";
    }

    private SpDeviceUtil() {
    }

    public static SpDeviceUtil getInstance() {
        return SingletonHolder.instance;
    }

    private static class SingletonHolder {
        private static final SpDeviceUtil instance = new SpDeviceUtil();
    }

    public void setDeviceList(String[] deviceList) {
        setEncryptValue(KEY_DEVICE_LIST, serialize(deviceList));
    }

    public String[] getDeviceList() {
        String[] ret = null;
        try {
            ret = (String[]) deSerialize(getEncryptValue(KEY_DEVICE_LIST));
        } catch (Exception e) {
            LogUtil.e(e.toString());
        }
        return ret;
    }
}
